package com.formerlyknownasprince.wheresmystuff;

import com.formerlyknownasprince.wheresmystuff.models.Item;
import com.formerlyknownasprince.wheresmystuff.models.LoginManager;
import com.formerlyknownasprince.wheresmystuff.models.Tag;
import com.formerlyknownasprince.wheresmystuff.models.User;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.support.v4.app.NavUtils;
/**
 * @author      Tim Swihart 		<email obscured since this file is public>
 * @version     0.1                 
 * @since       2013-03-04
 */
public class ItemInfoActivity extends Activity {
	Item shownItem = null;
	User currentUser = LoginManager.getInstance().getUser();
	LinearLayout llTagBar;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_item_info);
		// Show the Up button in the action bar.
		setupActionBar();
		
		// get the item to show
		//shownItem = currentUser.getItems().get(savedInstanceState.getInt("item_id"));
		
		// set up views		
		/*((TextView) findViewById(R.id.item_name)).setText(shownItem.getName());
		((TextView) findViewById(R.id.item_description)).setText(shownItem.getDescription());
		((TextView) findViewById(R.id.item_date)).setText(shownItem.getDate());
		((TextView) findViewById(R.id.item_reward)).setText(String.valueOf(shownItem.getReward()));
		
		llTagBar = (LinearLayout) findViewById(R.id.tag_bar_layout);
		for (Tag tag : shownItem.getTags()) {
			TextView tagView = new TextView(getApplicationContext());
			tagView.setText(tag.getTitle());
		}*/
	}

	/**
	 * Set up the {@link android.app.ActionBar}.
	 */
	private void setupActionBar() {

		getActionBar().setDisplayHomeAsUpEnabled(true);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.item_info, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

}
